// import com.alibaba.druid.sql.ast.*;
// import com.alibaba.druid.sql.visitor.SQLASTVisitor;

// import java.util.ArrayList;
// import java.util.List;

#include "SQLAlterIndexStatement.h"
#include "../../visitor/SQLASTVisitor.h"
#include "SQLExprTableSource.h"
#include "../../../utils/listTran.h"
#include "SQLAssignItem.h"
#include "../SQLPartitionBy.h"

SQLObject_ptr SQLAlterIndexStatement_Rebuild::getOption()
{
  return option;
}

void SQLAlterIndexStatement_Rebuild::setOption(SQLObject_ptr option)
{
  this->option = option;
}

// @Override
void SQLAlterIndexStatement_Rebuild::accept0(SQLASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(SQLAlterIndexStatement_Rebuild)))
  {
    acceptChild(visitor, option);
  }
  visitor->endVisit(SharedObject(SQLAlterIndexStatement_Rebuild));
}

SQLAlterIndexStatement::SQLAlterIndexStatement()
{
  partitions = std::make_shared<std::list<SQLAssignItem_ptr>>();
}
// @Override
void SQLAlterIndexStatement::accept0(SQLASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(SQLAlterIndexStatement)))
  {
    acceptChild(visitor, name);
    acceptChild(visitor, renameTo);
    acceptChild(visitor, table);
    SQLObject_list_ptr tmp1 = ListTran::tran_class<SQLAssignItem, SQLObject>(partitions);
    acceptChild(visitor, tmp1);
    acceptChild(visitor, rebuild);
    acceptChild(visitor, parallel);
  }
  visitor->endVisit(SharedObject(SQLAlterIndexStatement));
}

SQLName_ptr SQLAlterIndexStatement::getRenameTo()
{
  return renameTo;
}

void SQLAlterIndexStatement::setRenameTo(SQLName_ptr renameTo)
{
  this->renameTo = renameTo;
}

SQLExpr_ptr SQLAlterIndexStatement::getParallel()
{
  return parallel;
}

void SQLAlterIndexStatement::setParallel(SQLExpr_ptr parallel)
{
  this->parallel = parallel;
}

BOOL_ptr SQLAlterIndexStatement::getMonitoringUsage()
{
  return monitoringUsage;
}

void SQLAlterIndexStatement::setMonitoringUsage(BOOL_ptr monitoringUsage)
{
  this->monitoringUsage = monitoringUsage;
}

SQLAlterIndexStatement_Rebuild_ptr SQLAlterIndexStatement::getRebuild()
{
  return rebuild;
}

void SQLAlterIndexStatement::setRebuild(SQLAlterIndexStatement_Rebuild_ptr rebuild)
{
  this->rebuild = rebuild;
}

SQLName_ptr SQLAlterIndexStatement::getName()
{
  return name;
}

void SQLAlterIndexStatement::setName(SQLName_ptr name)
{
  this->name = name;
}

BOOL_ptr SQLAlterIndexStatement::isCompile()
{
  return compile;
}

void SQLAlterIndexStatement::setCompile(BOOL_ptr compile)
{
  this->compile = compile;
}

BOOL_ptr SQLAlterIndexStatement::getEnable()
{
  return enable;
}

void SQLAlterIndexStatement::setEnable(BOOL_ptr enable)
{
  this->enable = enable;
}

BOOL_ptr SQLAlterIndexStatement::isUnusable()
{
  return unusable;
}

void SQLAlterIndexStatement::setUnusable(BOOL_ptr unusable)
{
  this->unusable = unusable;
}

SQLExprTableSource_ptr SQLAlterIndexStatement::getTable()
{
  return table;
}

void SQLAlterIndexStatement::setTable(SQLName_ptr x)
{
  setTable(SQLExprTableSource_ptr(new SQLExprTableSource(x)));
}

void SQLAlterIndexStatement::setTable(SQLExprTableSource_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLAlterIndexStatement));
  }
  this->table = x;
}

SQLAssignItem_list_ptr SQLAlterIndexStatement::getPartitions()
{
  return partitions;
}

SQLPartitionBy_ptr SQLAlterIndexStatement::getDbPartitionBy()
{
  return dbPartitionBy;
}

void SQLAlterIndexStatement::setDbPartitionBy(SQLPartitionBy_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLAlterIndexStatement));
  }
  this->dbPartitionBy = x;
}

// @Override
SQLDDLStatement::DDLObjectType SQLAlterIndexStatement::getDDLObjectType()
{
  return SQLDDLStatement::DDLObjectType::INDEX;
}
